<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // Object.defineProperty ==> 该方法只会完成监控的对象属性的 栈 中值的变化
    let _arr = [1,2,3,4];
    let _user = { name:"tom" };
    let _msg = "msg变量"

    let obj = {};
    Object.defineProperty(obj,"arr",{
        get(){
            console.log("obj.arr-getter");
            return _arr;
        },
        set(nv){
            console.log("obj.arr-setter");
            _arr = nv;
        }
    })
    Object.defineProperty(obj,"user",{
        get(){
            console.log("obj.user-getter");
            return _user;
        },
        set(nv){
            console.log("obj.user-setter");
            _user = nv;
        }
    })
    Object.defineProperty(obj,"msg",{
        get(){
            console.log("obj.msg-getter");
            return _msg;
        },
        set(nv){
            console.log("obj.msg-setter");
            _msg = nv;
        }
    })

</script>
</html>